#! /bin/bash

#title           :ymy_git-config.sh
#description     :This script will create a yad dialog generating ssh-keys
#author		     :frimo
#date            :2020-05-25
#version         :0.1
#usage		     :ymy_git-config.sh
#notes           :This script should enable to generate ssh keys by gui
#    _    
# (///)(/ 
# /    /  

# create yad gui
dialog=$(yad --width=640 --title="yad my git-config" \
--center \
--text="Configure your GIT settings:" \
--image="../icon/ymy_64.png" \
--form \
--field="user.name" \
--field="user.email" \
--field="core.editor")
#--field="user.signingkey")

# get status of yad dialog
status=$?

# quit application if status is 0
[[ $status -eq 1 ]] && exit 0

# get values from yad dialog
username=$(echo $dialog | awk 'BEGIN {FS="|" } { print $1 }')
useremail=$(echo $dialog | awk 'BEGIN {FS="|" } { print $2 }')
coreeditor=$(echo $dialog | awk 'BEGIN {FS="|" } { print $3 }')
#usersigningkey=$(echo $dialog | awk 'BEGIN {FS="|" } { print $4 }')

# print created bash command
echo "git config --global user.name $username"
echo "git config --global user.email $useremail"
echo "git config --global core.editor $coreeditor"
#echo "git config --global user.signingkey $usersigningkey"

# execute created bash command
git config --global user.name $username
git config --global user.email $useremail
git config --global core.editor $coreeditor

# exit application
exit 0
